package com.cn.wanxi.service;

import com.cn.wanxi.dao.NewsDao;
import com.cn.wanxi.model.NewsModel;

import java.util.ArrayList;
import java.util.List;

public class NewsService {
    public List<NewsModel> getHomeService() {
        List<NewsModel> list = new ArrayList<>();
        NewsDao newsDao = new NewsDao();
        int length = newsDao.getStringListContent().size();
        for (int i = 0; i < length; i++) {
            NewsModel newsModel = new NewsModel();
            newsModel.setHref(newsDao.getStringListHref().get(i));
            newsModel.setTitle(newsDao.getStringListTitle().get(i));
            newsModel.setContent(newsDao.getStringListContent().get(i));
            list.add(newsModel);
        }
        return list;
    }
    public List<NewsModel> getNewsPageService() {
        List<NewsModel> list = new ArrayList<>();
        NewsDao newsDao = new NewsDao();
        int length = newsDao.getStringListContent().size();
        for (int i = 0; i < length; i++) {
            NewsModel newsModel = new NewsModel();
            newsModel.setHref(newsDao.getStringListHref().get(i));
            newsModel.setTitle(newsDao.getStringListTitle().get(i));
            newsModel.setContent(newsDao.getStringListContent().get(i));
            list.add(newsModel);
        }
        return list;
    }
}
